<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>

    // import {initMixin} from "../src/init";


    import {initState} from "../src/state";

    function Vue(options) {
        this._init(options)
    }

    initMixin(Vue)

    function initMixin(Vue) {
        Vue.prototype._init = function (options) {
            // 实例保存起来
            const vm = this
            // 传入的配置项挂载到实例上
            vm.$options = options
            // 调用生命周期钩子函数
            callHook(vm, 'beforeCreate') // 调用生命周期函数
            // 数据的挂载
            initState(vm)
            callHook(vm, 'created')
        }
    }

    function callHook(vm, method) {
        vm.$options[method]()
    }

    new Vue({
        el: '#app',
        beforeCreate() {
            console.log('234234')
        },
        created() {
            // 可以拿到数据了
        }
    })
</script>
</body>
</html>
